package com.air.ota.vo;

import com.air.ota.util.PkgUtil;

public class UTKDepositSyncUplinkVO extends UTKBaseUplinkPgkVO {
	
	protected byte[] cardAppSequence;
	protected byte[] syncSequence;
	protected byte   type;
	protected byte[] triggerSequence;
	protected byte   syncCount;
	protected byte[] lastTransData;
	protected byte[] pkgSequence;
	
	public UTKDepositSyncUplinkVO(byte[] cardSequence){
		super();
		this.cardSequence = cardSequence;
		
		cardAppSequence = new byte[8];
		syncSequence = new byte[2];
		triggerSequence = new byte[8];
		//lastTransData = new byte[14];
		pkgSequence = new byte[4];
	}
	
	public void parse(byte[] pkg){
		super.parse(pkg);
		decryptCmdData();
		
		System.arraycopy(this.cmdData, 0, this.cardAppSequence, 0, 8);
		System.arraycopy(this.cmdData, 8, this.syncSequence, 0, 2);
		type = cmdData[10];
		int lastTransDataLength=0;
		if (type==0x00){
			syncCount=cmdData[11];
			lastTransDataLength = 14*syncCount;
			lastTransData = new byte[lastTransDataLength];
			System.arraycopy(this.cmdData, 12, this.lastTransData, 0, lastTransDataLength);
			System.arraycopy(this.cmdData, 12+lastTransDataLength, this.pkgSequence, 0, 4);
		}else{//type==0x01
			System.arraycopy(this.cmdData, 11, this.triggerSequence, 0, 8);
			syncCount=cmdData[19];
			lastTransDataLength = 14*syncCount;
			lastTransData = new byte[lastTransDataLength];
			System.arraycopy(this.cmdData, 20, this.lastTransData, 0, lastTransDataLength);
			System.arraycopy(this.cmdData, 20+lastTransDataLength, this.pkgSequence, 0, 4);
		}
		PkgUtil.setCurrentPkgSequence(pkgSequence);
		
	}
	
	public byte[] getCardAppSequence() {
		return cardAppSequence;
	}

	public byte[] getSyncSequence() {
		return syncSequence;
	}

	public byte getType() {
		return type;
	}

	public byte[] getTriggerSequence() {
		return triggerSequence;
	}

	public byte getSyncCount() {
		return syncCount;
	}

	public byte[] getLastTransData() {
		return lastTransData;
	}

	public byte[] getPkgSequence() {
		return pkgSequence;
	}
	
	
	
	
}
